Skip to content

Conversation

mariopaja
Copy link
Contributor

@mariopaja mariopaja commented Oct 17, 2025

This PR enables SAI on STM32F4xx series by:

  1. Adding SAI1 A/B nodes
  2. Update DMA configurations for STM32F4xx
  3. Adding nucleo_f429zi in samples/drivers/i2s/output
stm32f4xx_sai

Audio Test:
2CH, 16bit, 44.1KHz, PCM5102a

stm32f4xx_sai.mp4

These changes enable SAI1 A & B nodes in STM32F4xx series.

Signed-off-by: Mario Paja <[email protected]>
STM32F4xx series shares several DMA configurations with
the other platforms. These changes aim to enable platform
specific DMA configuration and align them to other platforms.

Signed-off-by: Mario Paja <[email protected]>
Add nucleo_f429zi board in samples/drivers/i2s/output

Signed-off-by: Mario Paja <[email protected]>
Copy link

Please retry analysis of this Pull-Request directly on SonarQube Cloud

@anangl anangl removed their assignment Oct 20, 2025
Copy link
Contributor

@gautierg-st gautierg-st left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have several suggestions to replace the CONFIG_SOC_SERIES_XXX macros. I think it would ease the porting of other series featuring the SAI, and would also lighten the code a bit.

Comment on lines 320 to +322
#if !defined(CONFIG_SOC_SERIES_STM32H7X) && !defined(CONFIG_SOC_SERIES_STM32L4X) && \
!defined(CONFIG_SOC_SERIES_STM32G4X) && !defined(CONFIG_SOC_SERIES_STM32L5X)
!defined(CONFIG_SOC_SERIES_STM32G4X) && !defined(CONFIG_SOC_SERIES_STM32L5X) && \
!defined(CONFIG_SOC_SERIES_STM32F4X)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we replace all these defined with a single #if DT_HAS_COMPAT_STATUS_OKAY(st_stm32u5_dma) ?
That would probably make adding other series easier.

Copy link
Contributor Author

@mariopaja mariopaja Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do it on a separate PR after F7 is merged (and then I am node with almost all series), It is already in todo :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very well. Approved!

Comment on lines 331 to +333
#if !defined(CONFIG_SOC_SERIES_STM32H7X) && !defined(CONFIG_SOC_SERIES_STM32L4X) && \
!defined(CONFIG_SOC_SERIES_STM32G4X) && !defined(CONFIG_SOC_SERIES_STM32L5X)
!defined(CONFIG_SOC_SERIES_STM32G4X) && !defined(CONFIG_SOC_SERIES_STM32L5X) && \
!defined(CONFIG_SOC_SERIES_STM32F4X)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Comment on lines 352 to +354
#elif !defined(CONFIG_SOC_SERIES_STM32H7X) && !defined(CONFIG_SOC_SERIES_STM32L4X) && \
!defined(CONFIG_SOC_SERIES_STM32G4X) && !defined(CONFIG_SOC_SERIES_STM32L5X)
!defined(CONFIG_SOC_SERIES_STM32G4X) && !defined(CONFIG_SOC_SERIES_STM32L5X) && \
!defined(CONFIG_SOC_SERIES_STM32F4X)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Comment on lines 293 to +295
#if defined(CONFIG_SOC_SERIES_STM32H7X) || defined(CONFIG_SOC_SERIES_STM32L4X) || \
defined(CONFIG_SOC_SERIES_STM32G4X) || defined(CONFIG_SOC_SERIES_STM32L5X)
defined(CONFIG_SOC_SERIES_STM32G4X) || defined(CONFIG_SOC_SERIES_STM32L5X) || \
defined(CONFIG_SOC_SERIES_STM32F4X)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here we could maybe use #if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_dma_v1) || DT_HAS_COMPAT_STATUS_OKAY(st_stm32_dma_v2) ?

Comment on lines 469 to +470
/* Control of MCLK output from SAI configuration is not possible on STM32L4xx MCUs */
#if !defined(CONFIG_SOC_SERIES_STM32L4X)
#if !defined(CONFIG_SOC_SERIES_STM32L4X) && !defined(CONFIG_SOC_SERIES_STM32F4X)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is outdated (missing F4). This could be replaced with #ifdef SAI_MCK_OUTPUT_ENABLE to avoid having to add other series in future.

}

hdma->Instance = STM32_DMA_GET_INSTANCE(stream->reg, stream->dma_channel);
#if defined(CONFIG_SOC_SERIES_STM32F4X)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it could probably be #ifdef DMA_CHANNEL_1.

#endif

#if defined(CONFIG_SOC_SERIES_STM32H7X)
#if defined(CONFIG_SOC_SERIES_STM32H7X) || defined(CONFIG_SOC_SERIES_STM32F4X)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here #ifdef DMA_FIFOMODE_DISABLE

Comment on lines 483 to +484
/* MckOverSampling is not supported by all STM32L4xx MCUs */
#if !defined(CONFIG_SOC_SERIES_STM32L4X)
#if !defined(CONFIG_SOC_SERIES_STM32L4X) && !defined(CONFIG_SOC_SERIES_STM32F4X)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Could be replaced with #ifdef SAI_MCK_OVERSAMPLING_DISABLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants